package com.pms.mapper;

import com.github.pagehelper.Page;
import com.pms.dto.VehiclePageQueryDTO;
import com.pms.entity.Vehicle;
import com.pms.vo.VehiclePageQueryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface VehicleMapper {
    /**
     * 新增车辆信息
     * @param vehicle
     */
    @Insert("insert into vehicle(community_id, image, model, plate, owner_id) " +
            "VALUES (#{communityId},#{image},#{model},#{plate},#{ownerId})")
    void save(Vehicle vehicle);

    /**
     * 车辆分页查询
     * @param vehiclePageQueryDTO
     * @return
     */
    Page<VehiclePageQueryVO> pageQuery(VehiclePageQueryDTO vehiclePageQueryDTO);

    /**
     * 批量删除
     * @param id
     */
    @Delete("delete from vehicle where id=#{id}")
    void delete(Integer id);

    /**
     * 统计总数
     * @return
     */
    @Select("select count(*) from vehicle")
    Integer count();

}
